// created by jimmy 2016/3/5
/*打开登录窗口*/
var sureBtnCallBack;
var cancleBtnCallBack;

function showDialog() {
    $(".login-dialog").addClass("hide");
    $(".loading-box").addClass("hide");

    $(".alert-box").removeClass("hide");
    $(".index-login").removeClass("hide");
    setTimeout(function() {
        $(".login-bg").addClass("active");
        $(".alert-box").addClass("active");
    }, 10);
}

function dismissDialog() {
    sureBtnCallBack = null;
    cancleBtnCallBack = null;
    /*移除 active : opacity从 1 到 0*/
    $(".login-bg").removeClass("active");
    $(".alert-box").removeClass("active");
    setTimeout(function() {
        $(".index-login").addClass("hide");
    }, 300);
}

/*
    content, 中间内容
    sureCallBack,右边按钮 点击 回调
    sureText, 右边按钮 文字
    cancleCallBack,左边按钮 点击 回调
    cancleText，左边按钮 文字
*/
function openCommonAlert(content, sureCallBack, sureText, cancleCallBack, cancleText) {
    $(".alert-text").text(content);

    if (sureText != null)
        $(".sure-btn").text(sureText);
    if (cancleText != null)
        $(".cancle-btn").text(cancleText);

    if (sureCallBack != null || sureText != null)
        sureBtnCallBack = sureCallBack;
    else
        $(".sure-btn").addClass("hide");

    if (cancleCallBack != null || cancleText != null)
        cancleBtnCallBack = cancleCallBack;
    else
        $(".cancle-btn").addClass("hide");

    showDialog();
}


$(".cancle-btn").click(function() {
    if (cancleBtnCallBack != null)
        cancleBtnCallBack();
    dismissDialog();
});
$(".sure-btn").click(function() {
    if (sureBtnCallBack != null)
        sureBtnCallBack();
    dismissDialog();
});
